home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 271_02 / enterdat.doc < prev    next >
Text File  |  1987-08-18  |  3KB  |  78 lines

  1.  
  2.         NAME
  3.                 enterdata -- enter a string of data from keyboard
  4.                 dvid_enterdata -- same, use direct video access
  5.  
  6.         SYNOPSIS
  7.                 r = enterdata(dest, qty, row, col, mode);
  8.                 r = dvid_enterdata(dest, qty, row, col, mode);
  9.                 int r;          returns TRUE or FALSE
  10.                 char *dest;     destination for string
  11.                 int qty;        maximum allowable chars + 1
  12.                 int row, col;   row and column of string start*
  13.                 int mode;       mode for character checking
  14.  
  15.         DESCRIPTION
  16.         These routines are essentially the same, except that
  17.         dvid_enterdata uses the direct video access functions.
  18.         enterdata() provides a convenient method
  19.         for entering character strings from the keyboard and
  20.         verifying the character syntax.  Line editing is
  21.         supported to enhance user input.  Entry is as follows:
  22.            Carriage Return terminates input and returns TRUE.
  23.              If no other data was entered, destination string
  24.              is NULLed in the first position. CR is not placed
  25.              into destination.
  26.            ESCape terminates entry at once, NULLs destination,
  27.              clears screen field, and returns FALSE.
  28.            HOME clears field, and restarts entry without returning.
  29.            BACKSPACE and Cursor Left will destructively backspace
  30.              up to beginning of field.
  31.            Only qty - 1 characters will be accepted.
  32.            Any error sounds console BELL.
  33.         Various modes allow for checking of syntax and mapping
  34.         of characters:
  35.            Mode 0:   allow any printable character (ASCII 20H - 7FH)
  36.            Mode 1:   allow only alphabetics (A-Z, a-z)
  37.            Mode 2:   allow alphabetics and numerals only
  38.            Mode 3:   allow numerials only
  39.            Mode 4:   allow hexadecimal characters only (0-9, A-F, a-f)
  40.         Modes 0, 1, and 2 will map lower case to upper case if
  41.         decimal 128 (80H) is OR'd with the mode.
  42.  
  43.  
  44.  
  45.         * for enterdata only: If row = -1, then current cursor position
  46.           will be used, and col value is ignored.
  47.  
  48. Page 2   enterdata()
  49.  
  50.  
  51.         EXAMPLE
  52.  
  53.            char string[31];
  54.            unsigned int num;
  55.  
  56.            d_pos(10, 20, 0);      /* cursor to row 10, column 20 */
  57.            fputs("Enter an alphabetic string: ", stdout);
  58.            if(!enterdata(string, 31, 10, 48, 1)) {
  59.               fputs("\nESCape was pressed");
  60.               }
  61.            else printf("\nString entered is %s\n", string);
  62.  
  63.            fputs("Enter hex value at current cursor position: ", stdout);
  64.            if(!enterdata(string, 5, -1, 0, 4)) {
  65.               fputs("\nESCape was pressed");
  66.               }
  67.            else {
  68.               num = atoi(string);
  69.               printf("Number entered was %4x", num);
  70.               }
  71.  
  72.  
  73.  
  74.  
  75.  
  76.            
  77.         This function is found in SMTCx.LIB for the Turbo-C Compiler.
  78.